<?php

namespace App;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class Permission extends Model
{

    protected $fillable = [
        'name', 'label'
    ];
    public function roles(){
        return $this->belongsToMany(Role::class);
    }
    public function keytodata($keyname){
        return collect($keyname)->map(function($key){
            if(   $this->$key  instanceof Carbon ){
                return [$key=>$this->$key->toFormattedDateString()];
            }

            return [$key=>$this->$key];
        })->collapse()->toArray();



    }
}
